﻿<%@ Page Theme="BlueSkin" Language="C#" AutoEventWireup="true" CodeFile="start_learn_frame.aspx.cs" Inherits="start_learn_frame" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">

    <title></title>


<link rel="Stylesheet" type="text/css" href="CSS/allEN.css" />


    <script src="LmsScripts/AjaxSend.js" type="text/javascript"></script>

<script type="text/javascript">

     var RegisteredCourses = 
            {
                CurrentData : '',
                CoursesID : <%# mobjRegisteredCourses.CoursesID %> ,
                ScoID : -1 ,
                TotalSpendTime : <%# mobjRegisteredCourses.TotalSpendTime %> 
                
                                

            };
</script>

<script src="./LmsScripts/LmsAPI_1484_11.js" type="text/javascript"></script>


<script type="text/javascript">
    var API = new LMSAPI_1484_11();

</script>

<script type="text/javascript">
    
   
   

    


      var myXml = null;
            var bReturned = true;
            var xmlTime = -1;

            var startTime = null;

            var mainFrameDocument = null;

            function largeTick()
            {
                
               
                
                if (!bReturned)
                    return;

                    
                myXml = new ajaxRequest ();
                                             
                bReturned = false;
                xmlTime = 0;

                try
                {
                    if (myXml == false)
                    {
                        window.location="./loginen.aspx";
                    }
                }
                catch (ex)
                {
                    
                }

                myXml.onreadystatechange=function(){
                    if (myXml.readyState==4){
                        if (myXml.status==200){
                            
                            xmlTime = -1;
                            bReturned = true;
                            if (myXml.responseText.indexOf ("false") != -1)
                            {
                                //alert (myXml.responseText);
                                // server error no login user found
                                window.location="./loginen.aspx";
                            }
                            
                        }
                        else
                        {
                            //client error , no internet connection
                            window.location="./loginen.aspx";

                        }
                    }
                    
                }


                myXml.open("POST","./addRegCourseDataFrame.ashx",true);


                var currentTime = ((new Date()).getTime() - startTime)/1000;

                currentTime = Math.floor (currentTime);


                var TotalSpendTime = RegisteredCourses.TotalSpendTime + currentTime;

                //alert(TotalSpendTime);


                var params = "CoursesID=" + RegisteredCourses.CoursesID.toString() + 
                 "&TotalSpendTime=" + TotalSpendTime.toString() + "&CurrentData=" + RegisteredCourses.CurrentData.toString();

                //alert (params);

                myXml.setRequestHeader("Content-type", "application/x-www-form-urlencoded")

                myXml.send (params);

                


            }





             function smallTick()
            {
                
                if (!bReturned)
                {
                    xmlTime ++;

                    if (xmlTime > 50)
                    {
                        window.location = "./loginen.aspx";
                        
                    }
                }


                
                     getFrameDocument();

                   
                    RegisteredCourses.CurrentData =  mainFrameDocument.URL;
                
                

                   

                
                
                
               

                
                


            }


             function ab() {
                
                
                
                   setInterval (smallTick,200);
                   setInterval (largeTick,10000);
                
                
               
               
            }



            function getFrameDocument()
            {
                mainFrameDocument = document.getElementById('_MainFrame').contentDocument;
                if (mainFrameDocument == undefined)
                    mainFrameDocument = document.getElementById('_MainFrame').contentWindow.document;
            }


            function abStart() {
                var firstDate = new Date();
                startTime = firstDate.getTime();

                setTimeout(ab, 1000);
            }
			

            function FinishAll()
            {
                try
                {
                largeTick();

                }
                catch (Err)
                {
                }
            }


//             window.onbeforeunload = function()
//            {
//                try
//                {
//                    largeTick();
//                }
//                catch(err)
//                {
//                }

//                return "Are you sure you want to exit ?";
//                
//                
//            };


</script>


<script type="text/javascript">
    function hideit() {
        //document.getElementById('tdMain').width = "100%";
        //document.getElementById('tdToc').width = "0%";
        document.getElementById('tdToc').style.display = "none";

        document.getElementById('imgHide').style.display = "none";
        document.getElementById('imgShow').style.display = "inline";
    }


    function hideImgShow() {
        document.getElementById('imgShow').style.display = "none";
    }

    function showit() {
        //document.getElementById('tdMain').width = "100%";
        //document.getElementById('tdToc').width = "22%";
        document.getElementById('tdToc').style.display = "inline";

        document.getElementById('imgHide').style.display = "inline";
        document.getElementById('imgShow').style.display = "none";
    }



    function setHeight() {

        var height = 0;
        if (window.innerHeight != undefined)
            height = window.innerHeight;
        else
            height = document.documentElement.clientHeight;

        height = height - (height * 0.06);

        height = Math.floor(height);


        document.getElementById('_MainFrame').height = height;

        document.getElementById('dvTreeDiv').style.height = height.toString() + "px";

        //document.getElementById('frameToc').height = height;
    }

    //setHeight();


    window.onresize = function () {
        try {
            setHeight();
        }
        catch (Err) {
        }
    };


    function init() {

        abStart();



        return true;
    }


    

    
    </script>



</head>
<body  onload="setHeight();">
    <form id="form1" runat="server" style="font-size:1px;margin:0px;padding:0px;">
    
        <table cellpadding="0" cellspacing="0" width="100%">
            <tr>
                <td width="22%" id="tdToc" style="display:inline;">
                    <div id="dvTreeDiv" style="height:100%;overflow:auto;">
                                <asp:TreeView ID="tv1" runat="server"  
                                    Font-Size="10px"  AutoGenerateDataBindings="false">
                                <NodeStyle CssClass="toc"  />
        
                                <DataBindings>
            
                                    <asp:TreeNodeBinding   TextField="title" ValueField="id"  />
                                </DataBindings>
                            </asp:TreeView>
                        </div>
                    
                </td>
            
                <td>
                <img id="imgHide"  alt="Hide" title="Hide" src="getImage.ashx?image=images/hideit.gif&w=20&h=20&color=white"  style="vertical-align:top;display:inline;width:20px;height:20px;cursor:pointer;" onclick="hideit();" />
        <img id="imgShow"  alt="Show" title="Show" src="getImage.ashx?image=images/showit.gif&w=20&h=20&color=white" style="vertical-align:top;display:none;width:20px;height:20px;cursor:pointer;" onclick="showit();" />
                
                </td>
                

                <td width="100%" id="tdMain">
                    <iframe id="_MainFrame" name="_MainFrame" runat="server" src='' width="100%" style="margin:0px;padding:0px;" >
           
                    </iframe>
                </td>

            </tr>
        
        
        </table>




        

        <%--<iframe id="frameToc" name="frameToc"  runat="server" src='' width="22%" style="margin:0px;padding:0px;" >
           
        </iframe>--%>
        
        
        

        


       
    </form>


 
</body>
</html>
